package com.hyt.it.ogt.kq.main.controller.gov;


import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.common.apiInfor.DataType;
import com.hyt.common.apiInfor.ParamType;
import com.hyt.it.ogt.kq.common.gov.annotation.Progress;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.main.controller.base.BaseController;
import com.hyt.it.ogt.kq.common.config.exception.KqException;
import com.hyt.it.ogt.kq.service.gov.model.vo.AdmissionTicketPageVO;
import com.hyt.it.ogt.kq.service.gov.model.vo.ProgressVO;
import com.hyt.it.ogt.kq.service.gov.service.IProgressService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 准考证表 前端控制器
 * </p>
 *
 * @author huangyh
 * @since 2021-03-08
 */
@RestController
@Api(tags = "127.进度接口", value = "进度接口")
@ApiSort(value = 127)
@RequestMapping("/kq/progress")
@Slf4j
public class ProgressController extends BaseController {

    @Resource
    private IProgressService iProgressService;

    @ApiOperation(
            value = "27.1 获取进度", notes = "30000:获取进度成功", response = AdmissionTicketPageVO.class
    )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "taskId", value = "任务ID", dataType = DataType.STRING,
                    paramType = ParamType.QUERY, required = true),
            @ApiImplicitParam(name = "progressType", value = "进度类型(1：生成准考证进度，2：锁定和取消锁定，3：导出准考证，4：生成考务包，5：生成模拟测试考务包,6：考务绑定报名任务)",
                    dataType = DataType.STRING, paramType = ParamType.QUERY, required = true)
    })
    @ApiOperationSort(value = 1)
    @GetMapping("get")
    @Progress
    public ApiResponse<ProgressVO> get(@RequestParam String taskId, @RequestParam int progressType) {
        try {
            ProgressVO progressVO = iProgressService.get(taskId, progressType);
            return ApiResponse.<ProgressVO>builder().code(ResponseCode.SUCCESS.getCode()).data(progressVO).build();
        } catch (KqException e) {
            log.info("# 获取进度异常码：{}", e.getErrCode());
            return ApiResponse.<ProgressVO>builder().code(e.getErrCode()).build();
        }
    }

}
